package com.nbjtjc.safe.api.danger;

import com.nbjtjc.common.validator.ValidatorUtils;
import com.nbjtjc.safe.annotation.SysLog;
import com.nbjtjc.safe.bean.Page;
import com.nbjtjc.safe.bean.Result;
import com.nbjtjc.safe.model.danger.DangerSafePlanList;
import com.nbjtjc.safe.service.danger.IndexService;
import org.activiti.engine.TaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @auther guqianbin
 * 首页任务统计的接口
 * @date 2018/4/19 16:12
 **/
@RestController
@RequestMapping("/danger/index")
@CrossOrigin("*")
public class IndexController {
    @Autowired
    private IndexService indexService;

    @Autowired
    private TaskService taskService;

    @RequestMapping(value = "/", method = {RequestMethod.POST})
    public Result add(@RequestBody Page page) {
        Result result = indexService.index(page);
        return result;
    }

    /**
     * 获取员工岗位的统计信息，目前统计了隐患的相关检查次数
     * @param year
     * @return
     */
    @GetMapping("/userPostInfoCount/{year}")
    public Result userPostInfoCount(@PathVariable int year){
        Result result=indexService.userPostInfoCount(year);
        return result;
    }
    /**
     * 获取隐患首页的统计图的数据
     * @param year
     * @param companyId
     * @return
     */
    @GetMapping("/chartData/{year}/{companyId}")
    public Result indexChartData(@PathVariable int year,@PathVariable int companyId){
        Result result=new Result();
        result.setData(indexService.indexChartData(year,companyId));
        return result;
    }

    /**
     * 获取 最新的隐患
     * @param companyId
     * @return
     */
    @GetMapping("/latestDanger/{companyId}")
    public Result latestDanger(@PathVariable int companyId){
        Result result=new Result();
        result.setData(indexService.latestDanger(companyId));
        return result;
    }

    /**
     * 获取当前公司隐患任务的状态的统计
     * @param companyId
     * @return
     */
    @GetMapping("/dangerTaskCount/{companyId}")
    public Result dangerTaskCount(@PathVariable int companyId){
        Result result=new Result();
        result.setData(indexService.dangerTaskCount(companyId));
        return result;
    }
}
